package com.edu.admin.api;

import com.edu.service.task.TaskManager;
import com.edu.service.task.TaskParam;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

/**
 * 注解@SpringBootApplication默认扫描当前包，这样会导致无法扫描
 * 到com.education.service和com.education.common下的注解，
 * 此时就需要设置扫描包路径为com.education
 */
@SpringBootApplication(scanBasePackages = "com.edu")
public class App {
    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(App.class, args);
        // 获取TaskManager的实例
        TaskManager taskManager = applicationContext.getBean(TaskManager.class);
        // 定义任务参数
        TaskParam taskParam = new TaskParam();
        taskParam.setData("test");
        // 设置监听器bean实例名称
        taskParam.setTaskListenerBeanName("logTaskListener");
        taskManager.pushTask(taskParam);
        System.out.println(Thread.currentThread().getName());
    }
}